package com.example.blood_sugar.bean;

import java.util.Date;

/**
 * 存储记录的bean，按天存储，一天一条记录，包括BS，BP，HbAlc
 */
public class BSRecord {

    private Date date;
    private double dawn;
    private double beforeBreakfast = 0;
    private double afterBreakfast = 0;
    private double beforeLunch = 0;
    private double afterLunch = 0;
    private double beforeDinner = 0;
    private double afterDinner = 0;
    private double beforeSleep = 0;
    private int systolicBP = 0; // 收缩压
    private int diastolicBP = 0; // 舒张压
    private double saccharificationValue = 0; // 糖化值

    public BSRecord(){}

    public BSRecord(Date date){
        this.date = date;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public double getDawn() {
        return dawn;
    }

    public void setDawn(double dawn) {
        this.dawn = dawn;
    }

    public double getBeforeBreakfast() {
        return beforeBreakfast;
    }

    public void setBeforeBreakfast(double beforeBreakfast) {
        this.beforeBreakfast = beforeBreakfast;
    }

    public double getAfterBreakfast() {
        return afterBreakfast;
    }

    public void setAfterBreakfast(double afterBreakfast) {
        this.afterBreakfast = afterBreakfast;
    }

    public double getBeforeLunch() {
        return beforeLunch;
    }

    public void setBeforeLunch(double beforeLunch) {
        this.beforeLunch = beforeLunch;
    }

    public double getAfterLunch() {
        return afterLunch;
    }

    public void setAfterLunch(double afterLunch) {
        this.afterLunch = afterLunch;
    }

    public double getBeforeDinner() {
        return beforeDinner;
    }

    public void setBeforeDinner(double beforeDinner) {
        this.beforeDinner = beforeDinner;
    }

    public double getAfterDinner() {
        return afterDinner;
    }

    public void setAfterDinner(double afterDinner) {
        this.afterDinner = afterDinner;
    }

    public double getBeforeSleep() {
        return beforeSleep;
    }

    public void setBeforeSleep(double beforeSleep) {
        this.beforeSleep = beforeSleep;
    }

    public int getSystolicBP() {
        return systolicBP;
    }

    public void setSystolicBP(int systolicBP) {
        this.systolicBP = systolicBP;
    }

    public int getDiastolicBP() {
        return diastolicBP;
    }

    public void setDiastolicBP(int diastolicBP) {
        this.diastolicBP = diastolicBP;
    }

    public double getSaccharificationValue() {
        return saccharificationValue;
    }

    public void setSaccharificationValue(double saccharificationValue) {
        this.saccharificationValue = saccharificationValue;
    }

    /**
     * 取得所有血糖数据
     * @return
     */
    public double[] getDatas(){
        return new double[]{
                dawn,
                beforeBreakfast,
                afterBreakfast,
                beforeLunch,
                afterLunch,
                beforeDinner,
                afterDinner,
                beforeSleep
        };
    }

    /**
     * 通过sign获取相应数据
     * @param sign
     * @return
     */
    public double getDataBySign(int sign) {
        double result = 0;
        switch (sign){
            case 1: result = getDawn(); break;
            case 2: result = getBeforeBreakfast(); break;
            case 3: result = getAfterBreakfast(); break;
            case 4: result = getBeforeLunch(); break;
            case 5: result = getAfterLunch(); break;
            case 6: result = getBeforeDinner(); break;
            case 7: result = getAfterDinner(); break;
            case 8: result = getBeforeSleep(); break;
            case 11: result = getSystolicBP(); break;
            case 12: result = getDiastolicBP(); break;
        }
        return result;
    }

    /**
     * 通过sign设置相应数据
     * @param sign
     * @param data
     */
    public void setDataBySign(int sign, double data) {
        switch (sign){
            case 1: setDawn(data); break;
            case 2: setBeforeBreakfast(data); break;
            case 3: setAfterBreakfast(data); break;
            case 4: setBeforeLunch(data); break;
            case 5: setAfterLunch(data); break;
            case 6: setBeforeDinner(data); break;
            case 7: setAfterDinner(data); break;
            case 8: setBeforeSleep(data); break;
            case 11: setSystolicBP((int) data); break;
            case 12: setDiastolicBP((int) data); break;
        }
    }
}
